script_enemy_main{

let hpos1=-GetClipMinX;
let hpos2=GetClipMaxX/2;
let shift=0;

let character="Tomoko";
let spellcards=2;
if(GetCommonData("Difficulty")>=2){ spellcards=3; }
let dispelled=0;
let damagerate=10;
let outfit=1;
outfit=(128*outfit)-128;
let usespell=0;
let frame=0; let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let SEshotb7=("\script\SoundEffects\shotb7.wav");

let GRboss=("\script\Images\CharacterSprites\Tomoko.png");

#include_function "script/Functions/HealthBarLoad.txt";

@Initialize{
	LoadUserShotData("script\shots\ShotsTomoko1.txt");
	
	LoadSE("\script\SoundEffects\shotb7.wav");

	LoadGraphic("\script\Images\CharacterSprites\Tomoko.png");

	SetLife(250);
	SetTimer(40);
	SetInvincibility(120);
	SetDamageRate(10,10); 
	SetEnemyMarker(true);
	MagicCircle(true);
	SetMovePosition02(cx,miny+100,50);
}
	
@MainLoop{

SetCollisionA(GetX,GetY,16);
SetCollisionB(GetX,GetY,16);
SetShotAutoDeleteClip(32,32,32,32);

let weaken=1;
if(GetCommonData("BombOn")==0){ damagerate=10; }
if(GetCommonData("BombOn")==1){ damagerate=5; }
SetDamageRate(damagerate*weaken,damagerate*weaken);

HealthBar();

if(time%200==0 && time>=60){
	if(GetPlayerX>minx+50 && GetPlayerX<maxx-50){
	SetMovePosition01(GetPlayerX+rand(-30,30),rand(miny+60,miny+120),1.5);
	}
	if(GetPlayerX<=minx+50){
	SetMovePosition01(GetPlayerX+rand(15,30),rand(miny+60,miny+120),1.5);
	}
	if(GetPlayerX>=maxx-50){
	SetMovePosition01(GetPlayerX-rand(15,30),rand(miny+60,miny+120),1.5);
	}
}


if(GetCommonData("Difficulty")==1){
	if((time+0)%10==0 && time>=60){
	shift=rand(70,90);
		CreateShot02(minx+hpos1,cy,0,90+rand(-5,5),0.05,8,rand_int(119,121),20);
		CreateShot02(minx+hpos1,cy,0,270+rand(-5,5),0.05,8,rand_int(119,121),20);
	hpos1+=shift;
	if(hpos1>maxx){ hpos1-=maxx+40; }
	}
	if((time+5)%10==0 && time>=60){
		CreateShot02(minx+hpos2,cy,0,90+rand(-5,5),0.05,8,rand_int(119,121),20);
		CreateShot02(minx+hpos2,cy,0,270+rand(-5,5),0.05,8,rand_int(119,121),20);
	hpos2+=shift;
	if(hpos2>maxx){ hpos2-=maxx+40; }
	usespell=20;
	PlaySE(SEshotb7);
	}
} //Easy

//=============================================================================================================

if(GetCommonData("Difficulty")==2){
	if((time+0)%8==0 && time>=60){
	shift=rand(70,90);
		CreateShot02(minx+hpos1,cy,0,90+rand(-5,5),0.03,8,rand_int(119,121),20);
		CreateShot02(minx+hpos1,cy,0,270+rand(-5,5),0.03,8,rand_int(119,121),20);
	hpos1+=shift;
	if(hpos1>maxx){ hpos1-=maxx+40; }
	}
	if((time+4)%8==0 && time>=60){
		CreateShot02(minx+hpos2,cy,0,90+rand(-5,5),0.03,8,rand_int(119,121),20);
		CreateShot02(minx+hpos2,cy,0,270+rand(-5,5),0.03,8,rand_int(119,121),20);
	hpos2+=shift;
	if(hpos2>maxx){ hpos2-=maxx+40; }
	usespell=20;
	PlaySE(SEshotb7);
	}
} //Normal

//=============================================================================================================

if(GetCommonData("Difficulty")==3){
	if((time+0)%6==0 && time>=60){
	shift=rand(70,90);
		CreateShot02(minx+hpos1,cy,0,90+rand(-5,5),0.05,8,rand_int(119,121),20);
		CreateShot02(minx+hpos1,cy,0,270+rand(-5,5),0.05,8,rand_int(119,121),20);
	hpos1+=shift;
	if(hpos1>maxx){ hpos1-=maxx+40; }
	}
	if((time+3)%6==0 && time>=60){
		CreateShot02(minx+hpos2,cy,0,90+rand(-5,5),0.05,8,rand_int(119,121),20);
		CreateShot02(minx+hpos2,cy,0,270+rand(-5,5),0.05,8,rand_int(119,121),20);
	hpos2+=shift;
	if(hpos2>maxx){ hpos2-=maxx+40; }
	usespell=10;
	PlaySE(SEshotb7);
	}
} //Hard

//=============================================================================================================

if(GetCommonData("Difficulty")==4){
	if((time+0)%6==0 && time>=60){
	shift=rand(70,90);
		CreateShot02(minx+hpos1,cy,0,90+rand(-5,5),0.03,8,rand_int(119,121),20);
		CreateShot02(minx+hpos1,cy,0,270+rand(-5,5),0.03,8,rand_int(119,121),20);
	hpos1+=shift;
	if(hpos1>maxx){ hpos1-=maxx+40; }
	}
	if((time+3)%6==0 && time>=60){
		CreateShot02(minx+hpos2,cy,0,90+rand(-5,5),0.03,8,rand_int(119,121),20);
		CreateShot02(minx+hpos2,cy,0,270+rand(-5,5),0.03,8,rand_int(119,121),20);
	hpos2+=shift;
	if(hpos2>maxx){ hpos2-=maxx+40; }
	usespell=10;
	PlaySE(SEshotb7);
	}
} //Lunatic


time++; frame++;
if(usespell>0){ usespell--; } if(usespell<0){ usespell++; }
SetCommonData("Boss1X",GetX); SetCommonData("Boss1Y",GetY);

#include_function "script/Functions/HealthBar.txt";
}

@DrawLoop{
	SetGraphicScale(1,1);
	SetTexture(GRboss);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetRenderState(ALPHA);

	if(usespell>=1){ SetGraphicRect(384,outfit,512,outfit+128); }
	if(usespell<=-1){ SetGraphicRect(512,outfit,640,outfit+128); }

	if(usespell==0){
		if(GetSpeedX<=0.5 && GetSpeedX>=-0.5){ SetGraphicRect(0,outfit,128,outfit+128); }
		else if(GetSpeedX<-0.5){ SetGraphicRect(128,outfit,256,outfit+128); }
		else if(GetSpeedX>0.5){ SetGraphicRect(256,outfit,384,outfit+128); }
	}
	if(GetLife>0){ DrawGraphic(GetX,GetY); }
}
 
@Finalize{
}

}